function showDictSelect(id, type, all) {
	var data = getDict(type);
	var select = $("#" + id);
	select.empty();

	if (all != undefined || all) {
		select.append("<option value=''>全部</option>");
	}

	$.each(data, function(k, v) {
		select.append("<option value ='" + k + "'>" + v + "</option>");
	});

	return data;
}

function getDict(type) {
	var v = sessionStorage[type];
	if (v == null || v == "") {
		$.ajax({
			type : 'get',
			url : '/dicts?type=' + type,
			async : false,
			success : function(data) {
				v = {};
				$.each(data, function(i, d) {
					v[d.k] = d.val;
				});

				sessionStorage[type] = JSON.stringify(v);
			}
		});
	}

	return JSON.parse(sessionStorage[type]);
}



function showUserAllocationSelect(id) {
	var data = getUserAllocation();
	 console.log(data);
	var select = $("#" + id);
	//select.empty();
	$.each(data, function(k, v) {
		select.append("<option value ='" + k + "'>" + v + "</option>");
	});
	return data;
}
 

function sysRoleCheckbox(id){
	var data = getSysRoleList()
	var checkbox = $("#" + id);
	var i=0;
 
	$.each(data, function(k, v) {
		 
		i++;
		checkbox.append("<input type='checkbox' lay-skin='primary'  name='roleValue' value='"+k+"'/>"+v+"&nbsp;  ");
		 if(i%7==0){
		   checkbox.append("<br>");
		 }
		
	});
	 
 
	return data;
}

function getSysRoleList() {
	 var returnData;
		$.ajax({
			type : 'get',
			url : '/role/listCheckbox',
			async : false,
			success : function(data) {
				data = data.data;
				v = {};
				$.each(data, function(i, d) {
					v[d.k] = d.val;
				});
				returnData = JSON.stringify(v);
			}
		});
	return JSON.parse(returnData);
}


